home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
qbsub10.arc
/
SIMTIME.SUB
< prev
next >
Wrap
Text File
|
1986-06-24
|
2KB
|
55 lines
' SIMTIME.SUB -- MSDOS QuickBASIC time simulation utility 25 June 86
' by David L. Poskie (608) 274-9560
' 7118 Raymond Rd. Madison, WI 53719
' Please run any suggestions, corrections, additions, or changes by me.
' I can be messaged on all the major Madison, WI RBBS's.
SIMTIME:
'| Calculate simulated time/date subroutine based on real time clock
'| (1 second real time = 1 hour simulated time)
'|
'| To use: BaseLine = TIMER (Sets BaseLine)
'| Year = 1944 (Set year to 1944 or to your preference)
'| Month = 6 (Set month to 6 [June] or to your preference)
'| Day = 6 (Set day to 6 or to your preference)
'| Hour = 4 (Set hour to 0400 or to your preference)
'| This would place you ready for a dawn landing on the beach
'| at Normandy, on D-Day -- 6 June 1944 !
'|
'| Thereafter, any call to SIMTIME would give you a simulated time based
'| on your original settings, at the rate of 1 hour elapsed simulated
'| time for every second of elapsed real time. These subroutines are easy
'| to modify for different scales; e.g. 1 sec real time = 1 min sim time.
' Slice is the difference since last adjustment to BaseLine
Slice = TIMER - BaseLine
BaseLine = TIMER ' Reset BaseLine to current TIMER
' First pass on adjusting the variables
WHILE Slice > 8640 ' 8640 hours = 1 year
Slice = Slice - 8640 ' 24 hours * 30 days * 12 months = 8640
Year = Year + 1
WEND
WHILE Slice > 720 ' 720 hours = 1 month
Slice = Slice - 720 ' There's only 30-day months here
Month = Month + 1 ' 24 hours * 30 days = 720
WEND
WHILE Slice > 24 ' 24 hours = 1 day
Slice = Slice - 24
Day = Day + 1
WEND
Hour = Hour + Slice ' What's left
' Now, the only problem we may face is the case where Hour is > 24.
' If it is, it may require a full chain of recalculation:
' Second pass reconciles what's left
IF Hour > 24 _
THEN Day = Day + 1 : _
Hour = Hour - 24 ' Add a day and drop 24 hours
IF Day > 30 _
THEN Month = Month + 1 : _
Day = Day - 30 ' Add a month and drop 30 days
IF Month > 12 _
THEN Year = Year + 1 : _
Month = Month - 12 'Add a year and drop 12 months
RETURN
' >>>>> Physical EOF SIMTIME.SUB 25 June 86